<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/11
 * Time: 10:54
 */
namespace Assistant\Controller;
use Admin\Controller\AdminController;

class CenterController extends AdminController
{
    public function index(){
        $id = session('authId');
//        var_dump($id);
        $data = M('User')->find($id);
        $this->assign('data',$data);
        $this->display();
    }
    //修改密码页面展示
    public function updatePassword()
    {
        $this->display();
    }
    //修改密码ajax方法
    public function editPassword(){
        $old_password = md5(I('old_password'));
        $new_password = md5(I('password'));
        $id = session('authId');
        $data = M('User')->find($id);
        if($data['password']==$old_password){
            $_data['password'] = $new_password;
            $is_ok = M('User')->data($_data)->where(array('id'=>$id))->save();
            if($is_ok){
                $sign['status'] = 1;
                $this->ajaxReturn($sign);
            }
        }
        $sign['status'] = 0;
        $sign['sign'] = '旧密码错误！';
        $this->ajaxReturn($sign);
    }

    //测试数据
    public function test(){
        $data = array(
            array('id'=>1),
            array('id_time'=>1232323232),
        );
        $data = timeToStr($data);
        var_dump($data);
    }
    //清除缓存
    public function delCache(){
        $id = I('id');
        $id = getCommunityId($id);
        $communityId = explode(',',$id);
        $community = new \ZL\Community();
        foreach ($communityId as $v) {

            $community->getCommunity($v);
        }
        $data =  array();
        $data['status']=1;
        $this->ajaxReturn($data);
    }
}